package com.mvc.ligasDeportivas;

import com.beans.LigaBean;
import com.beans.UsuarioBean;
import com.gestores.GestionLigas;
import com.mvc.RequestHandler;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import java.io.IOException;
import javax.naming.NamingException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 *
 * @author victor
 */
public class FormModificarLiga implements RequestHandler {

    public void handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, NamingException {
        System.out.println("Inicio:FormModificarLiga");
        HttpSession sesion = request.getSession();
        UsuarioBean usuario = (UsuarioBean) sesion.getAttribute("usuario");
        
        String idLiga=request.getParameter("idLiga");
        String historica=request.getParameter("historica");
        
        if(GestionLigas.getInstance().usuarioValido(usuario, idLiga)){
            LigaBean liga=GestionLigas.getInstance().consultaLiga(idLiga);
            request.setAttribute("liga", liga);
            request.setAttribute("mensaje", null);
            request.setAttribute("historica", historica);
        }else{
            request.setAttribute("liga", null);
            request.setAttribute("mensaje", "No tiene permisos para la liga.");
        }
        System.out.println("Fin:FormModificarLiga");
    }

}
